﻿

using ExcelProject.Core.Validate;
using System.Reflection;

namespace ExcelProject.Core
{
    /// <summary>
    /// 特性扩展
    /// </summary>
    public static class CellExtend
    {
        /// <summary>
        /// 获取列名称
        /// </summary>
        /// <param name="prop"></param>
        /// <returns></returns>
        public static string GetCellName(PropertyInfo prop)
        {
            if (prop.IsDefined(typeof(CellNameAttribute), true))
            {
                CellNameAttribute? display = prop.GetCustomAttribute(typeof(CellNameAttribute)) as CellNameAttribute;
                if (display!=null) 
                {
                    return display.CellName;
                }
            }
            return prop.Name;
        }
    }
}
